//
//  BaseViewController.m
//  Project
//
//  Created by Jason on 15/12/1.
//  Copyright © 2015年 Happy. All rights reserved.
//

#import "BaseViewController.h"

@interface BaseViewController ()

@end

@implementation BaseViewController
@synthesize dataDicSource = _dataDicSource;
@synthesize dataSource = _dataSource;
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self resetBackButtonItem];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)resetBackButtonItem {
    NSArray *viewControllerArray = [self.navigationController viewControllers];
    
    long previousViewControllerIndex = [viewControllerArray indexOfObject:self] - 1;
    UIViewController *previous;
    
    if (previousViewControllerIndex >= 0) {
        previous = [viewControllerArray objectAtIndex:previousViewControllerIndex];
        previous.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc]
                                                     initWithTitle:@""
                                                     style:UIBarButtonItemStylePlain
                                                     target:self
                                                     action:nil];
    }
}


-(NSMutableArray *)dataSource{
    
    
    if (_dataSource) {
        
    }else{
        
        _dataSource = [NSMutableArray array].mutableCopy;
        
    }
    
    return _dataSource;
}

- (NSMutableDictionary *)dataDicSource{
    
    if (_dataDicSource) {
        
        
    }else{
        
        _dataDicSource = [NSMutableDictionary dictionary].mutableCopy;
        
    }
    
    return _dataDicSource;
}

/**
 *  请求错误提示
 *
 *  @param errorMsg
 */
- (void)requestErrorWithMsg:(NSString *)errorMsg{
    
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    hud.mode = MBProgressHUDModeText;
    hud.labelText = errorMsg;
    [hud hide:YES afterDelay:0.5];
    
}


/**
 *  请求正确时的提示。如：上传成功，缺少用户名....
 *
 *  @param Msg 提示语句
 */
- (void)requestSuccessWithMsg:(NSString *)Msg{
    
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    hud.mode = MBProgressHUDModeText;
    hud.labelText = Msg;
    [hud hide:YES afterDelay:0.5];
    
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
